package cn.sixmillions.demo01;

import cn.sixmillions.demo01.entity.Clazz;
import cn.sixmillions.demo01.entity.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * spring通过IOC容器绑定学生和班级关系
 */
public class Spring01Application {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("student-clazz-01.xml");
        Clazz oneClazz = context.getBean("oneClazz", Clazz.class);
        System.out.println(oneClazz.toString());
        Student s1 = context.getBean("s1", Student.class);
        s1.say();
        Student s2 = context.getBean("s2", Student.class);
        s2.say();
        Student s3 = context.getBean("s3", Student.class);
        s3.say();
    }
}
